/**
 * Copyright &copy; 2018-2018 <a href="#">聚成科技</a> All rights reserved.
 */
package com.jckj.core.service.impl;

import com.jckj.core.annotation.CurrentDataSource;
import com.jckj.core.dao.NotifySysUserViewMapper;
import com.jckj.core.db.DataSourceEnum;
import com.jckj.core.entity.Notify;
import com.jckj.core.entity.NotifySysUserView;
import com.jckj.core.entity.NotifySysUserViewExample;
import com.jckj.core.exception.ServiceException;
import com.jckj.core.service.NotifySysUserViewService;
import com.jckj.core.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * @author :liukuan
 * @date :2018-02-07
 */
@Service
@Transactional(readOnly = true,rollbackFor = ServiceException.class)
public class NotifySysUserViewServiceImpl implements NotifySysUserViewService {

  @Autowired
    private NotifySysUserViewMapper notifySysUserViewMapper;

    @Override
    @CurrentDataSource(DataSourceEnum.SLAVE)
    public List<NotifySysUserView> findByNotify(Notify notify) {
        NotifySysUserViewExample example=new NotifySysUserViewExample();
        NotifySysUserViewExample.Criteria criteria = example.createCriteria();
        if(StringUtils.isNotBlank(notify.getId())){
            criteria.andIdEqualTo(notify.getId());
        }
        if(StringUtils.isNotBlank(notify.getType())){
            criteria.andTypeEqualTo(notify.getType());
        }
        return notifySysUserViewMapper.selectByExample(example);
    }
}
